package com.estate.struts.actions;

import java.text.ParseException;

import com.estate.business.ThingsTodoService;
import com.estate.utils.ProjectConstants;
import com.estate.utils.ThingsTodoUtil;
import com.estate.vo.impl.ThingsTodoVo;

public class 模板备份 extends EstateSupport {
	
	private String content;
	private String state;
	private String beginDate;
	private String overDate;
	
	private ThingsTodoService thingsService;
	
	private String method;

	@Override
	public String execute() throws Exception {
		System.out.println("method ================= " + this.getMethod());

		String page = "";
		
		if("add".equals(this.getMethod())){
			ThingsTodoVo thingsVo = this.getAddThingsVo();
			boolean result = this.getThingsService().addThingsTodo(thingsVo);
			if(result){
				page=this.SUCCESS;
			}else{
				page="fail";
			}
		}else if("modify".equals(this.getMethod())){
			
		}else if("update".equals(this.getMethod())){
			
		}else if("delete".equals(this.getMethod())){
			
		}else if("list".equals(this.getMethod())){
			
		}else if("detail".equals(this.getMethod())){
			
		}else{
			page="fail";
		}
		return page;
	}
	
	private ThingsTodoVo getAddThingsVo(){
		ThingsTodoVo thingsVo = new ThingsTodoVo();
		try {
			thingsVo.setUser(this.getSessionUser());
			thingsVo.setBeginDate(ProjectConstants.SIMPLE_DATE.parse((this.getBeginDate())));
			thingsVo.setOverDate(ProjectConstants.SIMPLE_DATE.parse(this.getOverDate()));
			thingsVo.setContent(this.getContent());
			thingsVo.setState(ThingsTodoUtil.getThingsString(Integer.parseInt(this.getState())));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return thingsVo;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(String beginDate) {
		this.beginDate = beginDate;
	}

	public String getOverDate() {
		return overDate;
	}

	public void setOverDate(String overDate) {
		this.overDate = overDate;
	}

	public ThingsTodoService getThingsService() {
		return thingsService;
	}

	public void setThingsService(ThingsTodoService thingsService) {
		this.thingsService = thingsService;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}
}
